<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%-- 
    JSP Name : da_200_01E.jsp
    Description : CSR News List
    author Seung Hun
    since 2012. 8. 20.
    version 1.0
    Modification Information
       since          author              description
    ===========    =============    ===========================
    2012. 8. 20.     Seung Hun     최초 생성
--%>
<%@ include file="/WEB-INF/jsp/co/mn/include/declare.jspf" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>CSR News &#124; HMC CSR</title>
<meta name="description" content="The CSR News Bulletin provides the latest updates on the various CSR activities and services HMC provides in many countries around the world." />
<meta name="keywords" content="HMC CSR News Bulletin, CSR News Bulletin on the Americas, CSR News Bulletin on Europe, CSR News Bulletin on the Asia-Pacific, CSR News Bulletin on the Middle East, CSR News Bulletin on Africa" />
<%@ include file="/WEB-INF/jsp/co/us/include/header.jspf" %>
<link rel="stylesheet" type="text/css" href="/css/usr/eng.css" media="screen" />
<meta name="description" content="" />
<meta name="keywords" content="" />
<script type="text/javaScript" language="javascript">
$(document).ready(function() {
    /* form validation check */
    onloadCharCheck();
    
    /* 대륙 List Ajax */
    getContCd();

    $("#srchButn").bind("click", moveSearch);    // 검색
    $("#srchTxt").bind("keydown", eventEnter);    // 엔터키 제어
});

/*  
 * 페이징
 */
function movePage(num) {
    $("#currentPageNo").val(num);
    $("#mainForm").attr('action','/da_200_01.do').submit();
}

/*
 * 검색
 */
function moveSearch() {
    if (!isSchrChk($("#srchTxt").val())) {
        alert("Results will not be able to enter special characters.");
        $("#srchTxt").focus();
        return false;
    }
    
    $("#currentPageNo").val("1");
    $("#mainForm").attr('action','/da_200_01.do').submit();
}

/*
 * 검색 Text EnterKey 처리
 */
function eventEnter() {
    if (event.key == 13) {
        moveSearch();
    }
}

/*
 * 상세페이지 이동
 */
function moveMdfyPage(idx) {
    $("#blbIdx").val(idx);
    $("#mainForm").attr('action','/da_200_02.do').submit();
}

/*
 * 대륙 코드 리스트
 */
function getContCd() {
    var url = "/CO000014.do";
    
    ajaxSubmit(url, "", callbackContListJson);
}

/*
 * 대륙 코드 리스트 Ajax 결과
 */
function callbackContListJson(jsonData) {
    var evalData = eval(jsonData);
    
    if (evalData.jsonArray.length > 0 || evalData.jsonArray != null) {
        for (var i = 0; i < evalData.jsonArray.length; i++) {
            if (evalData.jsonArray[i].dept2Idx == "${rqInfo.contCd}") {
                $("#contCd").append("<option value=\"" + evalData.jsonArray[i].dept2Idx + "\" selected>" + evalData.jsonArray[i].val + "</option>");
            } else {
                $("#contCd").append("<option value=\"" + evalData.jsonArray[i].dept2Idx + "\">" + evalData.jsonArray[i].val + "</option>");
            }
        }
    }
    
    var contCd = "${rqInfo.contCd}";
    if(contCd != null && contCd != ""){
        getNatCd($("#contCd").val());    
    }
    
}

/*
 * 국가코드리스트
 */
function getNatCd(val) {
    var url = "/CO000015.do";
    var param = "dept2Idx=" + val;
    
    ajaxSubmit(url, param, callbackNatListJson);
}

/*
 * 국가코드리스트 Ajax 결과
 */
function callbackNatListJson(jsonData) {
    var evalData = eval(jsonData);
    
    $("#natCd").empty().data('options'); 
    $("#natCd").append("<option value=\"\" selected>Sort</option>");
    if (evalData.jsonArray.length > 0 || evalData.jsonArray != null) {
        for (var i = 0; i < evalData.jsonArray.length; i++) {
            if (evalData.jsonArray[i].dept3Idx == "${rqInfo.natCd}") {
                $("#natCd").append("<option value=\"" + evalData.jsonArray[i].dept3Idx + "\" selected>" + evalData.jsonArray[i].val + "</option>");
            } else {
                $("#natCd").append("<option value=\"" + evalData.jsonArray[i].dept3Idx + "\">" + evalData.jsonArray[i].val + "</option>");
            }
        }
    }
}
</script>
</head>
<body>
<div id="wrap">

    <!-- top -->
    <%@ include file="/WEB-INF/jsp/co/us/include/topE.jsp" %>
    <!-- top -->

    <!-- container -->
    <div id="container">
        <div id="contentsWrap">
            <div id="contentsArea">
                <div class="headingArea">
                    <h2>CSR News</h2>
                </div>
                <div id="contetns">
                    <div class="location">
                        <a href="/ma_100_01.do">Home</a>
                        <a href="/da_100_01.do">CSR Materials</a>
                        <span>CSR News</span>
                    </div>
                    <form id="mainForm" name="mainForm" method="post">
                        <input type="hidden" id="currentPageNo" name="currentPageNo" value="${paginationInfo.currentPageNo}" />
                        <input type="hidden" id="blbIdx" name="blbIdx" value="" />
                        <input type="hidden" id="delIdx" name="delIdx" value="" />
                        
                        <%-- Locale --%>
                        <input type="hidden" id="CSR_LOCALE_PARAM" name="CSR_LOCALE_PARAM" value="en" />
                    <div class="searchArea">
                        <p class="pageResult"><span class="totalNum">${paginationInfo.totalRecordCount}</span> posts in total, Current Page:  <span> ${paginationInfo.currentPageNo}/${paginationInfo.totalPageCount}</span> </p>
                        <div id="search">
                            <fieldset>
                                <legend class="invisible">Search</legend>
                                <select id="contCd" name="contCd" onchange="getNatCd(this.value);" style="width:100px;">
                                    <option value="">Continent</option>
                                </select>
                                <select id="natCd" name="natCd">
                                    <option value="">Sort</option>
                                </select>
                                <select id="srchScn" name="srchScn">
                                    <option value="" <c:if test="${rqInfo.srchScn == '' }"><c:out value="selected" /></c:if>>ALL</option>
                                    <option value="titl" <c:if test="${rqInfo.srchScn == 'titl' }"><c:out value="selected" /></c:if>>Title</option>
                                    <option value="sbc" <c:if test="${rqInfo.srchScn == 'sbc' }"><c:out value="selected" /></c:if>>Contetns</option>
                                </select>
                                <input type="text" class="formSearch" id="srchTxt" name="srchTxt" value="${rqInfo.srchTxt }" title="검색어" minbyte="1" maxlength="10" /><input type="image" src="/img/usr/eng/btn/btn_search_font.gif" id="srchButn" name="srchButn" title="search" alt="search" />
                            </fieldset>
                        </div>
                    </div>
                    <table border="1" class="tableList" summary="CSR 소식의 번호,구분,제목,등록일이 기재 되어있는 표">
                        <colgroup>
                            <col width="8%" />
                            <col width="17%" />
                            <col width="50%" />
                            <col width="15%" />
                        </colgroup>
                        <thead>
                            <tr>
                                <th>No.</th>
                                <th>Region</th>
                                <th>Subject</th>
                                <th>Last Updated</th>
                            </tr>
                        </thead>
                        <tbody>
                        <c:choose>
                            <c:when test="${resultList != null && !empty resultList }">
                                <c:forEach var="result" items="${resultList }" varStatus="status">
                            <tr>
                                <td class="num">${result.blbNo }</td>
                                <td>${result.contCd }&#124;${result.natCd }</td>
                                <c:if test="${fn:length(result.titl) > 35 }">
                                <td class="dirLeft"><a href="#" onclick="moveMdfyPage('${result.blbIdx }');return false;">${fn:substring(result.titl,0,35) }...</a></td>
                                </c:if>
                                <c:if test="${fn:length(result.titl) <= 35 }">
                                <td class="dirLeft"><a href="#" onclick="moveMdfyPage('${result.blbIdx }');return false;">${result.titl }</a></td>
                                </c:if>
                                <td class="num">${result.rgstDt }</td>
                            </tr>
                                </c:forEach>
                            </c:when>
                            <c:otherwise>
                            <tr>
                                <td colspan="4">No Data.</td>
                            </tr>
                            </c:otherwise>
                        </c:choose>
                        </tbody>
                    </table>
                    </form>
                    <div class="pageNate">
                        <able:pagination paginationInfo="${paginationInfo }" type="image" jsFunction="movePage" />
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- /container -->

    <!-- footer -->
    <%@ include file="/WEB-INF/jsp/co/us/include/bottomE.jsp" %>
    <!-- /footer -->
    
</div>
</body>
</html>